package io.zerous.engine

import android.content.Context
import android.view.View
import io.zerous.engine.math.Vector2

/**
 * Created by Zerous on 2018/2/4.
 */

class TouchEvent {
    public var type: Int = 0
    public var x: Int = 0
    public var y: Int = 0
    public var pointer: Int = 0
}

class Input(context: Context, view: View) {

    data class KeyEvent(
            var type: Int = 0,
            var keyCode: Int = 0,
            var keyChar: Char = '0'
    )

    val touchPoint: Vector2 = Vector2()

    val touchHandler = TouchHandler(view)
    val keyHandler = KeyHandler(view)

    fun isKeyPressed(keyCode: Int): Boolean = keyHandler.isKeyPressed(keyCode)

    fun isTouchDown(pointer: Int): Boolean = touchHandler.isTouchDown(pointer)

    fun getTouchX(pointer: Int): Int = touchHandler.getTouchX(pointer)

    fun getTouchY(pointer: Int): Int = touchHandler.getTouchY(pointer)

    fun getTouchPoint(pointer: Int): Vector2 = touchPoint.set(getTouchX(pointer).toFloat(), getTouchY(pointer).toFloat())
}